package com.conncui.subscript.adapter;

import java.util.List;

import com.conncui.subscript.R;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class TabViewPagerAdapter<T> extends PagerAdapter {
    Context mContext;
    LayoutInflater mLayoutInflater;
    private List<T> mList;

    public TabViewPagerAdapter(Context context, List<T> list) {
        this.mContext = context;
        this.mList = list;
        this.mLayoutInflater = LayoutInflater.from(this.mContext);
    }

    public Object instantiateItem(ViewGroup container, int position) {
        View itemView = this.mLayoutInflater.inflate(R.layout.item_view_pager_textview, container, false);
        ((TextView) itemView.findViewById(R.id.text_view)).setText((String) this.mList.get(position));
        container.addView(itemView);
        return itemView;
    }

    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }

    public void startUpdate(ViewGroup container) {
        super.startUpdate(container);
    }

    public void finishUpdate(ViewGroup container) {
        super.finishUpdate(container);
    }

    public void setPrimaryItem(ViewGroup container, int position, Object object) {
        super.setPrimaryItem(container, position, object);
    }

    public int getItemPosition(Object object) {
        return super.getItemPosition(object);
    }

    public CharSequence getPageTitle(int position) {
        return super.getPageTitle(position);
    }

    public float getPageWidth(int position) {
        return super.getPageWidth(position);
    }

    public int getCount() {
        return this.mList.size();
    }

    public boolean isViewFromObject(View view, Object object) {
        return view == ((View) object);
    }

    public List<T> getList() {
        return this.mList;
    }

    public void setList(List<T> list) {
        this.mList = list;
    }
}
